#!/bin/bash

# 读取ipPwd.txt文件
while IFS= read -r line
do
    line_array+=("$line")
done < ipPwd.txt

for line in "${line_array[@]}";
do
   # 提取IP地址和密码
    ip=$(echo "$line" | awk '{print $1}')
    password=$(echo "$line" | awk '{print $2}')
    echo "-------$ip----$password---------"
    # 使用sshpass连接并验证密码
    sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$ip" "echo Password is correct." &> /dev/null

    # 判断密码的正确性并将结果输出到aaa.txt文件
    if [ $? -eq 0 ]; then
        echo "IP: $ip Password: $password [Password is correct.]" >> aaa.txt
    else
        echo "IP: $ip Password: $password [Password is incorrect.]" >> aaa.txt
    fi
done
